Skip to content

[Bugfix #563] Fix shell buttons broken by stale scrollState in safeFit()#564

Merged
waleedkadous merged 1 commit intomainfrom
builder/bugfix-563-shell-buttons-stopped-working-
Feb 26, 2026
Merged

[Bugfix #563] Fix shell buttons broken by stale scrollState in safeFit()#564
waleedkadous merged 1 commit intomainfrom
builder/bugfix-563-shell-buttons-stopped-working-

Conversation

@waleedkadous
Copy link
Contributor

Summary

  • Reverts safeFit() condition from if (!baseY && !scrollState.baseY) back to if (!baseY)baseY from term.buffer.active is not affected by display:none toggling, so scrollState.baseY is unnecessary and can become stale
  • Keeps scrollState.wasAtBottom and scrollState.viewportY usage (the core Issue Terminal still scrolls to top of buffer (regression from #423) #560 fix for viewport position preservation)
  • Adds regression test for the stale scrollState.baseY scenario

Root Cause

PR #561 added !scrollState.baseY to the safeFit() early-return condition. When scrollState.baseY retained a stale positive value (e.g., after buffer clear or terminal reset), safeFit() would take the scroll-preserving path even when the buffer had no scrollback (baseY=0). This caused incorrect scroll restoration with stale position values, interfering with terminal rendering and button interaction.

Test Plan

  • All 176 dashboard unit tests pass (175 existing + 1 new regression test)
  • Dashboard builds successfully (npx vite build)
  • New regression test covers the stale scrollState.baseY scenario
  • Manual verification: shell buttons (+ Shell, shell tabs) work after fix

Fixes #563

PR #561 changed safeFit()'s early-return condition from `if (!baseY)` to
`if (!baseY && !scrollState.baseY)`, adding a dependency on the externally-
tracked scrollState.baseY. This was unnecessary because baseY (from
term.buffer.active.baseY) reflects actual buffer scrollback and is NOT
affected by display:none toggling — unlike viewportY which the external
tracking was designed to protect.

The stale scrollState.baseY could cause safeFit() to take the scroll-
preserving path when the buffer had no scrollback (e.g., after a clear),
leading to incorrect scroll restoration with stale position values.

Fix: Revert to `if (!baseY)` while keeping scrollState.wasAtBottom and
scrollState.viewportY for position values (the core Issue #560 fix).

Adds regression test for the stale scrollState.baseY scenario.

Fixes #563
@waleedkadous
Copy link
Contributor Author

Architect Review

One-liner: stale scrollState.baseY was causing safeFit() to take the scroll-preserving path on empty/fresh buffers, calling scrollToLine() with bogus values. Reverting to if (!baseY) fixes it — baseY from buffer.active is reliable.

Good regression test. Approved.


Architect review

@waleedkadous waleedkadous merged commit 9681943 into main Feb 26, 2026
6 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-563-shell-buttons-stopped-working- branch February 26, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell buttons stopped working after scroll fix (#561)

1 participant